package org.sockettest.client;

import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class SenderThread implements Runnable {
    private final Socket socket;
    public SenderThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try (Scanner scanner = new Scanner(System.in); PrintWriter out = new PrintWriter(socket.getOutputStream())){
            while (true){
                System.out.println("Input: ");
                String str = scanner.nextLine();
                out.println(str);
                out.flush();
                if("bye".equals(str)){
                    break;
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
